<h1><span class="reg_ico"></span><?= lang('label_menu_link_addressbooks'); ?></h1>

<ul class="breadcrumb">
    <li><a href="<?= base_url() ?>"><?= lang('label_home') ?></a></li>
    <li><a href="<?= base_url('user/profile') ?>"><?= lang('label_profile') ?></a></li>
    <li><a href="<?= base_url('advertise') ?>"><?= lang('label_menu_link_advertise') ?></a></li>
    <li><?= lang('label_add'); ?></li>
</ul>


<div class="page">
    <?php $this->load->view('template/default/user/top') ?>

        <div style="overflow:hidden;">

            <?php $this->load->view('template/default/user/side') ?>

            <div class="profile_page">
    <form class="forms inside_1" action="<?php echo current_url() ?>" method="post" enctype="multipart/form-data">


        <div class="text">
            <label for="url"><?= lang('label_link') ?>  :</label>
            <samp>
                <input type="text" name="url" id="url" placeholder="e.g http://www.mtjar.com" value="<?= form_val('url') ?>">
            </samp>
        </div>

        <div class="browse">
            <label for="image"><?= lang('label_adv') ?> :</label>
            <samp>
                <input type="file" id="image" name="image"  /><label for="image"></label>
                <strong>{ 210px Width * 260px Height }</strong>
            </samp>
        </div>

        <div class="select">
            <label for="showtype"><?= lang('label_adv_show_type') ?> :</label>
            <samp>
                <select name="showtype" id="showtype">
                    <option value=""><?= lang('label_select_show_type') ?></option>
                    <option value="click" <?php if (form_val('showtype') == 'click') echo 'selected' ?> ><?= lang('label_adv_click') ?></option>
                    <option value="view" <?php if (form_val('showtype') == 'view') echo 'selected' ?> ><?= lang('label_adv_view') ?></option>
                </select>
            </samp>
        </div>

        <div id="click" style="margin-top: 10px; padding: 15px;display: none">
            <h3 style="color: red"><?= str_replace('%price%', $click_price, lang('message_per_click_price')) ?></h3>
            <div class="text">
                <label for="clicksnum"><?= lang('label_clicks_num') ?> :</label>
                <samp><input data-rel="num" pattern="[0-9]*" type="number" name="clicksnum" id="clicksnum" value="<?= form_val('clicksnum') ?>" > </samp>
            </div>
            <div class="text">
                <label for="clickscost"><?= lang('label_cost') . ' (' . lang('label_hallallah') . ')' ?> :</label>
                <samp><input data-rel="cost" pattern="[0-9]*" type="number" name="clickscost" id="clickscost"  value="<?= form_val('clickscost') ?>" > </samp>
            </div>
        </div>

        <div id="view" style="margin-top: 10px; padding: 15px;display: none">
            <h3 style="color: red"><?= str_replace('%price%', $view_price, lang('message_per_view_price')) ?></h3>
            <div class="text">
                <label for="viewsnum"><?= lang('label_views_num') ?> :</label>
                <samp><input data-rel="num" pattern="[0-9]*" type="number" name="viewsnum" id="viewsnum" value="<?= form_val('viewsnum') ?>" > </samp>
            </div>
            <div class="text">
                <label for="viewscost"><?= lang('label_cost') . ' (' . lang('label_hallallah') . ')' ?> :</label>
                <samp><input data-rel="cost" pattern="[0-9]*" type="number" name="viewscost" id="viewscost"  value="<?= form_val('viewscost') ?>" > </samp>
            </div>
        </div>

        <div class="submit">
            <input name="submit" value="<?= lang('label_add') ?>" type="submit" >
        </div>

    </form>
            </div></div></div>

<script type="text/javascript">
    $(document).ready(function() {
        $('#showtype').change(function() {
            if ($(this).val() == 'click') {
                $('#view').hide()
                $('#click').show(500)
            } else if ($(this).val() == 'view') {
                $('#click').hide()
                $('#view').show(500)
            } else {
                $('#click').hide()
                $('#view').hide()
            }

            $('[data-rel=cost]').val('')
            $('[data-rel=num]').val('')

        });

        $('[data-rel=num]').keyup(function() {
            if ($('#showtype').val() == 'click' && $('#clicksnum').val() != '') {
                $('#clickscost').val(parseInt($(this).val()) * parseInt('<?= $click_price ?>'));
            } else if ($('#showtype').val() == 'view' && $('#viewsnum').val() != '') {
                $('#viewscost').val(parseInt($(this).val()) * parseInt('<?= $view_price ?>'));
            }
        })

        $('[data-rel=cost]').keyup(function() {
            if ($('#showtype').val() == 'click' && $('#clickscost').val() != '') {
                $('#clicksnum').val(parseInt(parseInt($(this).val()) / parseInt('<?= $click_price ?>')));
            } else if ($('#showtype').val() == 'view' && $('#viewscost').val() != '') {
                $('#viewsnum').val(parseInt(parseInt($(this).val()) / parseInt('<?= $view_price ?>')));
            }
        })

        $('#showtype').change();
        $('[data-rel=cost]').val('<?php
if (form_val('clickscost'))
    echo form_val('clickscost');
elseif (form_val('viewscost'))
    echo form_val('viewscost');
?>')
        $('[data-rel=num]').val('<?php
if (form_val('clicksnum'))
    echo form_val('clicksnum');
elseif (form_val('viewsnum'))
    echo form_val('viewsnum');
?>')
    })
</script>